package org.ash.consumer.feign.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.ash.consumer.feign.service.FeignService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class ConsumerFeignController {

    @Resource
    private FeignService feignService;
    @GetMapping("consumer/feign/test/{message}")
    public String test(@PathVariable String message) {
        long start = System.currentTimeMillis();
        log.info("调用provider开始，{}", start);
        String result = null;
        try {
            result = feignService.getProviderTest(message);
        } catch (Exception e) {
            log.info("调用provider结束，{}ms", System.currentTimeMillis()-start);
            throw new RuntimeException(e);
        }
        return result;
    }
}
